﻿package PinballCode.Screens {
	
	import flash.display.MovieClip;
	import PinballCode.MainApp;
	import flash.events.MouseEvent;
	
	// CreditScreen Class
	public class CreditScreen extends Screen {
		
		//constuctor
		public function CreditScreen(m:MainApp) {
			// constructor code
			super(m);
			init();
		}
		
		// initalizes screen
		public function init()
		{
			//////////////////////////////////TO BE CHANGED
			//hard coded values for the location of the screen
			this.x = 300;
			this.y = 250;
		}
		
		// brings in the screen to be displayed
		public override function bringIn()
		{
			// the next line calls the superclass' bringIn();
			super.bringIn();
			
			//////////////////////////////////TO BE CHANGED
			//hard coded values for the location of the screen
			
			// set up the buttons
			CreditBackButton_mc.addEventListener(MouseEvent.CLICK, backToMenu);
			StartButton_mc.addEventListener(MouseEvent.CLICK, startGame);
		}
		
		// Starts the game Screen
		public function startGame(e:MouseEvent)
		{
			removeListeners();
			app.displayScreen(Game);
		}
		// Starts the mainMenu Screen
		public function backToMenu(e:MouseEvent)
		{
			removeListeners();
			app.displayScreen(MainMenu);
		}
		// removes the button listeners
		public function removeListeners()
		{
			StartButton_mc.removeEventListener(MouseEvent.CLICK, startGame);
			CreditBackButton_mc.removeEventListener(MouseEvent.CLICK, backToMenu);
		}
	}
	
}
